﻿using System;
using System.IO;
using System.Data;
using System.Text;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Resources;

using CE.Mail;
using CE.User;
using CE.Global;
using CE.InputOut;
using CE.Database;
using CE.CarInsurance;
using CXDecryption;

public partial class carinsurance_UpdateCIPendingApplication : System.Web.UI.Page
{
    int _currentRow = 0;
    private DateTime dateTimeNow = CE.Global.General.GetUTCDateTime();

    protected override void InitializeCulture()
    {
        String selectedCulture = CE.Global.General.SetCulture();
        base.InitializeCulture();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null)
        {
            Response.Redirect("~/SiteUserSecureLogin.aspx");
        }
        if (!IsPostBack)
        {
            lblSearchMessage.Text = "";
            pnlMessage.Visible = false;
            divCar.Visible = false;
            
            pnlDetails.Visible = false;
            btnUpdate.Enabled = true;
            UploadButton.Enabled = true;
            lblUpdateMessage.Text = "";
            lblUpdateError.Text = "";
            txtCarId.Text = "";
            txtLastQuoteRefNo.Text = "";
            txtLastStep.Text = "";
            ddlOption.Items.Clear();
            ddlOption.Items.Add(new ListItem("Please Select", "0"));
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',false);", true);
        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        Span1.InnerHtml = "";
        ClearFields();
        pnlMessage.Visible = false;
        pnlOptionMessage.Visible = false;
        lblOptionMessage.Text = "";
        if (Server.HtmlEncode(txtSearch.Text).Trim() != "")
        {
            txtCarId.Text = CE.Global.General.GetCarId(Server.HtmlEncode(txtSearch.Text).Trim());
            LoadApplicationDetails();
            if (txtCarId.Text.Trim() != "")
            {
                GetPaymentDetails();
                GetCarMoreDetails();
            }
        }
        else
        {
            ClearFields();
        }
       
        if (txtCancelStatus.Text != "" && Convert.ToInt32(txtCancelStatus.Text.Trim()) > 0)
        {
            
            ddlOption.Items.Clear();
            ddlOption.Items.Add(new ListItem("Please Select", "0"));
            ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Retrieve, "RTRV"));
        }
    }
   
    protected void UploadButton_Click(object sender, EventArgs e)
    {
        int _fileSize = 0;
        int _fileCount = 0;
        CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
        string _filePath = GetPdfFilePath(Convert.ToInt64(txtProviderId.Text.Trim()), lblUpRefNo.Text.Trim());

        HttpFileCollection uploads;
        uploads = HttpContext.Current.Request.Files;
        for (int a = 0; a < uploads.Count; a++)
        {
            if (uploads[a].ContentLength > 0)
            {
                try
                {
                    _fileSize += uploads[a].ContentLength;
                    _fileCount = _fileCount + 1;
                }
                catch (Exception ex)
                {
                }
            }
        }
        if (uploads.Count == 0)
        {
            ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
        }
        string[] _OriginalFile = new string[_fileCount];
        string[] _fileName = new string[_fileCount];
        if ((_fileSize / 1024) < 1025)
        {
            _myIO.DeleteDirectory(_filePath);
            bool _IsPDF = true;
            for (int a = 0; a < uploads.Count; a++)
            {
                if (_IsPDF == true)
                {
                    if (uploads[a].ContentLength > 0)
                    {
                        FileInfo _f = new FileInfo(System.IO.Path.GetFileName(uploads[a].FileName));
                        if (_f.Extension.ToUpper().ToString() != ".PDF")
                        {
                            _IsPDF = false;
                        }
                    }
                }
            }
            if (_IsPDF == true)
            {
                for (int i = 0; i < uploads.Count; i++)
                {
                    if (uploads[i].ContentLength > 0)
                    {
                        try
                        {
                            int DocNo = i + 1;
                            _fileName[i] = lblUpRefNo.Text.Trim() + "_" + DocNo.ToString();
                            _OriginalFile[i] = System.IO.Path.GetFileName(uploads[i].FileName);
                            if (i == 0)
                            {
                                FileField1.PostedFile.SaveAs(_filePath + _fileName[i] + ".pdf");
                            }
                            else if (i == 1)
                            {
                                FileField2.PostedFile.SaveAs(_filePath + _fileName[i] + ".pdf");
                            }
                            else if (i == 2)
                            {
                                FileField3.PostedFile.SaveAs(_filePath + _fileName[i] + ".pdf");
                            }
                            Span1.InnerHtml = Resources.General.FileUploadSuccessfully;
                            if (DocNo == _fileCount)
                            {
                                Int64 _uploadResult = 0;
                                int _uploadCount = 0;
                                string _DocRefNo = "";
                                Int32 _DocId = 0;
                                DateTime _tDate = new DateTime();
                                _tDate = dateTimeNow;
                                _DocRefNo = _tDate.Year.ToString("0000") + _tDate.Month.ToString("00") + _tDate.Day.ToString("00") + _tDate.Hour.ToString("00") + _tDate.Minute.ToString("00") + _tDate.Second.ToString("00");
                                _DocRefNo += txtCarId.Text.Trim() + "A" + Session[General.UserId].ToString();
                                CarFileUpload _carfileupload = new CarFileUpload();
                                CarFileUploadDB _carfileuploaddb = new CarFileUploadDB();
                                for (int p = 0; p < _fileCount; p++)
                                {
                                    _DocId = p + 1;
                                    _carfileupload.CarId = Convert.ToInt64(txtCarId.Text.Trim());
                                    _carfileupload.ProviderCompanyId = Convert.ToInt64(txtProviderId.Text.Trim());
                                    _carfileupload.InsuranceType = "CI";
                                    _carfileupload.AgentId = Convert.ToInt64(Session[General.UserId].ToString());
                                    _carfileupload.DocRefNo = _DocRefNo;
                                    _carfileupload.DocumentNo = _DocId;
                                    _carfileupload.FileName = _filePath + _fileName[p].ToString() + ".pdf";
                                    _carfileupload.OriginalName = _OriginalFile[p].ToString();
                                    _carfileupload.Status = true;
                                    _uploadResult = _carfileuploaddb.Insert(_carfileupload);
                                    _uploadCount += 1;
                                }
                                if (_uploadCount == DocNo)
                                {
                                    txtTitle.Text = "";
                                    txtDispalcement.Text = "";
                                    txtWeight.Text = "";
                                    txtNumberofSeat.Text = "";
                                    txtEngineNumber.Text = "";
                                    txtChassisNumber.Text = "";
                                    txtReceiptNo.Text = "";
                                    pnlOptionMessage.Visible = true;
                                    lblOptionMessage.Text = Resources.General.FileUploadSuccessfully;
                                    pnlDetails.Visible = true;
                                    //pnlUpload.Visible = false;
                                }
                                else
                                {
                                    Span1.InnerHtml = Resources.General.UploadFileNameSaveFailed;
                                    ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Span1.InnerHtml = Resources.General.FileUploadFailed;
                            ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
                        }
                    }
                }
            }
            else
            {
                Span1.InnerHtml = Resources.General.PDFformat;
                ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
            }
        }
        else
        {
            Span1.InnerHtml = Resources.General.Maximum1MB;
            ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
        }
    }
    
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        lblUpdateMessage.Text = "";
        lblUpdateError.Text = "";
        if (Page.IsValid)
        {
            string _refNo = GetReferenceNumber(txtCarId.Text.Trim(), txtProviderId.Text.Trim());
            string _fileName = _refNo + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
            string _filePath = GetExcelFilePath(Convert.ToInt64(txtProviderId.Text.Trim()), lblUpRefNo.Text.Trim());
            string _ExcelFilePath = "";
            string[] _fileList = new string[0];
            string[] _pdffileList = new string[0];

            CarMoreDetails _carmoredetails = new CarMoreDetails();
            CarMoreDetailsDB _carmoredetailsdb = new CarMoreDetailsDB();
            Int64 _result = -1;
            Int64 _payresult = -1;
            _carmoredetails.CarId = Convert.ToInt64(txtCarId.Text.Trim());
            _carmoredetails.ProviderCompanyId = Convert.ToInt64(txtProviderId.Text.Trim());
            _carmoredetails.Name = lblUpApplicantName.Text.Trim();
            _carmoredetails.Title = Server.HtmlEncode(txtTitle.Text);
            _carmoredetails.Dispalcement = txtDispalcement.Text;
            _carmoredetails.VehicleWeight = txtWeight.Text;
            _carmoredetails.NumberofSeat = Convert.ToInt16(txtNumberofSeat.Text.Trim());
            _carmoredetails.EngineNumber = Server.HtmlEncode(txtEngineNumber.Text);
            _carmoredetails.ChassisNumber = Server.HtmlEncode(txtChassisNumber.Text);
            _carmoredetails.RefCEUserId = Convert.ToInt64(txtUserId.Text.Trim());
            _carmoredetails.AgentId = Convert.ToInt64(Session[General.UserId].ToString());
            _carmoredetails.Status = true;

            _result = _carmoredetailsdb.Insert(_carmoredetails);
            if (_result > 0)
            {
                Int64 CarId = Convert.ToInt64(txtCarId.Text.Trim());
                Int64 ProviderCompanyId = Convert.ToInt64(txtProviderId.Text.Trim());
                
                ProposalSummary _proposalsummary = new ProposalSummary();
                ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
                _proposalsummary.CECarId = CarId;
                _proposalsummary.ProviderCompanyId = ProviderCompanyId;
                _proposalsummary.ReceiptNo = txtReceiptNo.Text.Trim();
                _proposalsummary.PaymentStatus = true;
                _proposalsummary.AgentId = Convert.ToInt64(Session[General.UserId].ToString());
                _proposalsummary.Info10 = _filePath + _fileName + ".xls";
                _payresult = _proposalsummarydb.UpdatePaymentStatus(_proposalsummary);
                
                if (_payresult > 0)
                {
                    _ExcelFilePath = GenerateExcel(ProviderCompanyId, CarId, "CI", _filePath, _fileName);

                    string _CustName, _Today, _QuoteRefNo, _CustAddress, _Payment, _OrderRefNo, _CoverTypeDesc, _AnnualPremium, _MakeModelDesc, _CustEmail;
                    _CustName = ""; _Today = ""; _QuoteRefNo = ""; _CustAddress = ""; _Payment = ""; _OrderRefNo = ""; _CoverTypeDesc = "";
                    _AnnualPremium = ""; _MakeModelDesc = ""; _CustEmail = "";

                    DataSet _dsUserData = new DataSet();
                    _dsUserData = _proposalsummarydb.GetCompletedUserItem(CarId, ProviderCompanyId);
                    if (_dsUserData != null && _dsUserData.Tables.Count > 0 && _dsUserData.Tables[0].Rows.Count > 0)
                    {
                        _CustName = _dsUserData.Tables[0].Rows[0]["Name"].ToString();
                        _Today = _dsUserData.Tables[0].Rows[0]["Today"].ToString();
                        _QuoteRefNo = _dsUserData.Tables[0].Rows[0]["QuoteRefNo"].ToString();
                        _CustAddress = _dsUserData.Tables[0].Rows[0]["CustAddress"].ToString();
                        if (_dsUserData.Tables[0].Rows[0]["Payment"].ToString() == "BT")
                        {
                            if (ddlLanguage.Text == "TH")
                            {
                                _Payment = "ผ่านบัญชีธนาคาร";
                            }
                            else if (ddlLanguage.Text == "EN")
                            {
                                _Payment = "Bank Transfer";
                            }
                        }
                        else if (_dsUserData.Tables[0].Rows[0]["Payment"].ToString() == "CC")
                        {
                            if (ddlLanguage.Text == "TH")
                            {
                                _Payment = "บัตรเครดิต";
                            }
                            else if (ddlLanguage.Text == "EN")
                            {
                                _Payment = "Credit Card";
                            }
                        }

                        _OrderRefNo = _dsUserData.Tables[0].Rows[0]["OrderRefNo"].ToString();
                        _CoverTypeDesc = _dsUserData.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
                        _AnnualPremium = _dsUserData.Tables[0].Rows[0]["AnnualPremium"].ToString();
                        _MakeModelDesc = _dsUserData.Tables[0].Rows[0]["MakeModelDesc"].ToString();
                        _CustEmail = _dsUserData.Tables[0].Rows[0]["Email"].ToString();
                    }

                    string imgUrl = "http://" + CE.Configuration.MyConfigurationManager.GetAppSettingValue("LogoPath");
                    string mailBody = "";
                    string _emailTitle = "";
                    string _toemail = "";
                    string _ccemail = "";
                    string _bccemail = "";

                    mailBody += "<html>";
                    mailBody += "<head>";
                    mailBody += "<title></title>";
                    mailBody += "<style type='text/css'>";
                    mailBody += "body{ font-family:Arial, Helvetica, sans-serif; font-size:14px;}";
                    mailBody += "p{line-height: 1.5em; padding:0; margin:0;}";
                    mailBody += ".line{border-bottom: 1px #000 solid; padding-bottom: 1px;}";
                    mailBody += ".tblbrd{ border: 2px solid #000;}";
                    mailBody += "</style>";
                    mailBody += "</head>";
                    mailBody += "<body>";

                    if (ddlLanguage.Text == "TH")
                    {
                        _emailTitle = "การยืนยันประกันภัยรถยนต์ สำหรับ กล้วยๆ.com [" + _QuoteRefNo + "]";

                        mailBody += "<table width='670' border='0' cellpadding='2' cellspacing='2' class='tblbrd'>";
                        mailBody += "<tr><td><table width='100%' border='0' cellspacing='2' cellpadding='0'>";
                        mailBody += "<tr>";
                        mailBody += "<td width='140' height='100' rowspan='4'><img src='" + imgUrl + "' alt='GluayGluay' width='120' height='100' /></td>";
                        mailBody += "<td><b>บริษัทคอมแพร์เอ็กซ์เพรส นายหน้าประกันวินาศภัย (ประเทศไทย) จำกัด</b></td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td>ชั้น 42 อาคารยูไนเต็ด เซ็นเตอร์ เลขที่ 323 ถนนสีลม แขวงสีลม เขตบางรัก กรุงเทพฯ 10500</td></tr>";
                        mailBody += "<tr><td>โทร 02-268-8222 โทรสาร 02-266-6321</td></tr>";
                        mailBody += "<tr><td>อีเมล์: support@gluaygluay.com</td></tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "<tr><td height='25' align='center'><b>เอกสารยืนยันการได้รับค่าเบี้ยประกันภัย</b></td></tr>";
                        mailBody += "<tr><td align='right'><table width='100%' border='0' cellpadding='0' cellspacing='2'>";
                        mailBody += "<tr>";
                        mailBody += "<td align='right'>&nbsp;</td>";
                        mailBody += "<td width='100' align='right'>วันที่ : &nbsp;</td>";
                        mailBody += "<td width='100' align='left' class='line'>" + _Today + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td align='left'>ได้รับค่าเบี้ยประกันภัย จาก</td>";
                        mailBody += "<td width='100' align='right'>เลขที่อ้างอิง: &nbsp;</td>";
                        mailBody += "<td width='100' align='left' class='line'>" + _QuoteRefNo + "</td>";
                        mailBody += "</tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td><table width='100%' border='0' cellspacing='2' cellpadding='0'>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>คุณ:</td>";
                        mailBody += "<td valign='top' class='line'>" + _CustName + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>ที่อยู่ :</td>";
                        mailBody += "<td valign='top' class='line'>" + _CustAddress + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td height='10' colspan='2' valign='top'>&nbsp;</td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>ประเภทกรมธรรม์:</td>";
                        mailBody += "<td valign='top' class='line'>" + _CoverTypeDesc + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>ยี่ห้อรถยนต์/รุ่นรถยนต์:</td>";
                        mailBody += "<td valign='top' class='line'>" + _MakeModelDesc + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td height='10' colspan='2' valign='top'>&nbsp;</td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td colspan='2' valign='top'><table width='100%' border='0' cellspacing='0' cellpadding='0'>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150'>เบี้ยประกันภัยรายปี เป็นเงิน </td>";
                        mailBody += "<td width='150' class='line'>" + _AnnualPremium + "</td>";
                        mailBody += "<td width='150' colspan='2'>&nbsp;&nbsp;บาท &nbsp; (รวมอากรแสตมป์และภาษีมูลค่าเพิ่ม)</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td height='10' colspan='4'></td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td>ชำระโดย</td>";
                        mailBody += "<td class='line'>" + _Payment + "</td>";
                        mailBody += "<td width='150' align='right'>หมายเลขอ้างอิง &nbsp;&nbsp;</td>";
                        mailBody += "<td class='line'>" + _OrderRefNo + "</td>";
                        mailBody += "</tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td><span class='line'><br />หมายเหตุ</span>";
                        mailBody += "<p>เอกสารฉบับนี้จัดทำด้วยระบบคอมพิวเตอร์ ถือว่าสมบูรณ์โดยไม่ต้องมีลายมือชื่อผู้รับมอบอำนาจ<br /></p></td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td>ใบเสร็จรับเงินตัวจริงจะทำการออกให้ท่านโดยบริษัทประกันฯ และส่งให้ท่านพร้อมกับกรมธรรม์ต่อไป</td>";
                        mailBody += "</tr></table><br />";
                        mailBody += "</body>";
                        mailBody += "</html>";
                    }
                    else if (ddlLanguage.Text == "EN")
                    {
                        _emailTitle = "Car Insurance Submission on GluayGluay.com [" + _QuoteRefNo + "]";

                        mailBody += "<table width='670' border='0' cellpadding='2' cellspacing='2' class='tblbrd'>";
                        mailBody += "<tr><td><table width='100%' border='0' cellspacing='2' cellpadding='0'>";
                        mailBody += "<tr>";
                        mailBody += "<td width='140' height='100' rowspan='4'><img src='" + imgUrl + "' alt='GluayGluay' width='120' height='100' /></td>";
                        mailBody += "<td><b>CompareXpress Insurance Broker (Thailand) Ltd.</b></td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td>42nd Floor, United Center Building, 323 Silom Road, Bangrak, Bangkok 10500</td></tr>";
                        mailBody += "<tr><td>t : +66 2 268 8222  f : +66 2 266 6321</td></tr>";
                        mailBody += "<tr><td>e: support@gluaygluay.com</td></tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "<tr><td height='25' align='center'><b>Confirmation of Insurance Premium Payment</b></td></tr>";
                        mailBody += "<tr><td align='right'><table width='100%' border='0' cellpadding='0' cellspacing='2'>";
                        mailBody += "<tr>";
                        mailBody += "<td align='right'>&nbsp;</td>";
                        mailBody += "<td width='100' align='right'>Date: &nbsp;</td>";
                        mailBody += "<td width='100' align='left' class='line'>" + _Today + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td align='left'>Premium received from</td>";
                        mailBody += "<td width='100' align='right'>Ref No: &nbsp;</td>";
                        mailBody += "<td width='100' align='left' class='line'>" + _QuoteRefNo + "</td>";
                        mailBody += "</tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td><table width='100%' border='0' cellspacing='2' cellpadding='0'>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>Name:</td>";
                        mailBody += "<td valign='top' class='line'>" + _CustName + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>Address:</td>";
                        mailBody += "<td valign='top' class='line'>" + _CustAddress + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td height='10' colspan='2' valign='top'>&nbsp;</td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>Type of policy:</td>";
                        mailBody += "<td valign='top' class='line'>" + _CoverTypeDesc + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150' valign='top'>Make/Model:</td>";
                        mailBody += "<td valign='top' class='line'>" + _MakeModelDesc + "</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td height='10' colspan='2' valign='top'>&nbsp;</td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td colspan='2' valign='top'><table width='100%' border='0' cellspacing='0' cellpadding='0'>";
                        mailBody += "<tr>";
                        mailBody += "<td width='150'>Annual Premium</td>";
                        mailBody += "<td width='150' class='line'>" + _AnnualPremium + "</td>";
                        mailBody += "<td width='150' colspan='2'>&nbsp;&nbsp;Baht &nbsp; (Duty Stamp &amp; VAT Included)</td>";
                        mailBody += "</tr>";
                        mailBody += "<tr><td height='10' colspan='4'></td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td>Paid by</td>";
                        mailBody += "<td class='line'>" + _Payment + "</td>";
                        mailBody += "<td width='150' align='right'>Reference no. &nbsp;&nbsp;</td>";
                        mailBody += "<td class='line'>" + _OrderRefNo + "</td>";
                        mailBody += "</tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "</table></td></tr>";
                        mailBody += "<tr>";
                        mailBody += "<td><span class='line'><br />Remarks</span>";
                        mailBody += "<p>This is computer generated confirmation, no signature is required<br /></p></td>";
                        mailBody += "</tr>";
                        mailBody += "<tr>";
                        mailBody += "<td>The official receipt of premium payment will be issued by the insurance company upon policy approval and will be sent together with policy documents</td>";
                        mailBody += "</tr></table><br />";
                        mailBody += "</body>";
                        mailBody += "</html>";
                    }

                    _toemail = _CustEmail;
                    _ccemail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("CC");
                    _bccemail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("BCC");

                    MyMailManager.SendToCustomer(_toemail, _ccemail, _bccemail, _emailTitle, mailBody);

                    DataSet _dsCarFileUpload = new DataSet();
                    CarFileUploadDB _carfileuploaddb = new CarFileUploadDB();
                    _dsCarFileUpload = _carfileuploaddb.GetCarFileUploadList(CarId, ProviderCompanyId);
                    if (_dsCarFileUpload != null && _dsCarFileUpload.Tables.Count > 0 && _dsCarFileUpload.Tables[0].Rows.Count > 0)
                    {
                        _fileList = new string[_dsCarFileUpload.Tables[0].Rows.Count + 1];
                        for (int b = 0; b < _dsCarFileUpload.Tables[0].Rows.Count; b++)
                        {
                            _fileList[b] = _dsCarFileUpload.Tables[0].Rows[b]["FileName"].ToString();
                        }
                        _fileList[_dsCarFileUpload.Tables[0].Rows.Count] = _ExcelFilePath.ToString();
                    }

                    string _ProMailBody, _ProEmailTitle, _ProToEmail, _ProCCEmail, _ProBCCEmail, _ProviderName, ProviderBrokerCode;
                    _ProMailBody = ""; _ProEmailTitle = ""; _ProToEmail = ""; _ProCCEmail = ""; _ProBCCEmail = "";
                    _ProviderName = GetProviderName(Convert.ToInt64(txtProviderId.Text.Trim()));
                    ProviderBrokerCode = GetProviderBrokerCode(Convert.ToInt64(txtProviderId.Text.Trim()));

                    _ProEmailTitle = "ส่งงานประกันรถยนต์ – motor insurance application from CompareXpress [" + _QuoteRefNo + "]";
                    _ProMailBody += "<br>เรียน ฝ่ายพิจารณารับประกัน บริษัท  " + _ProviderName + ",<br><br>";
                    _ProMailBody += "บริษัท คอมแพร์เอ็กซ์เพรส นายหน้าประกันภัย (ประเทศไทย) จำกัด, เลขที่นายหน้า [" + ProviderBrokerCode + "]  มีความประสงค์ขอส่งงานประกันภัยรถยนต์ตามรายละเอียดในไฟล์แนบ<br><br>";
                    _ProMailBody += "กรุณาติดต่อ 0-2268-8222 ต่อ 2229 หากข้อมูลไม่ครบถ้วน หรือหากต้องการสอบถามรายละเอียดเพิ่มเติม ขอบคุณค่ะ<br><br>";
                    _ProMailBody += "ขอแสดงความนับถือ<br/><br>";
                    _ProMailBody += "<hr align='left' width='410px' /><br>";
                    _ProMailBody += "<b>CompareXpress Insurance Broker (Thailand) Ltd.</b><br>";
                    _ProMailBody += "42nd Floor, United Center Building,<br />";
                    _ProMailBody += "323 Silom Road, Bangrak, <br />";
                    _ProMailBody += "Bangkok 10500<br />";
                    _ProMailBody += "t : +66 2 268 8222<br />";
                    _ProMailBody += "f : +66 2 266 6321 <br />";

                    string _ProkiderKey = GetProviderMail(Convert.ToInt64(txtProviderId.Text.Trim()));
                    _ProToEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue(_ProkiderKey);
                    _ProCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("CC");
                    _ProBCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("BCC");
                    MyMailManager.SendToProviderWithAttach(_ProToEmail, _ProCCEmail, _ProBCCEmail, _ProEmailTitle, _ProMailBody, _fileList);

                    
                    pnlDetails.Visible = false;
                    pnlOptionMessage.Visible = true;
                    lblOptionMessage.Text = Resources.General.SuccessfullyUpdated;
                    lblUpdateMessage.Text = Resources.General.SuccessfullyUpdated;
                    lblUpdateError.Text = "";
                   
                    LoadApplicationDetails();
                    if (txtCarId.Text.Trim() != "")
                    {
                        GetPaymentDetails();
                        GetCarMoreDetails();
                    }
                }
                else
                {
                    lblUpdateMessage.Text = "";
                    lblUpdateError.Text = Resources.General.UpdateFaild;
                }
            }
            else
            {
                lblUpdateMessage.Text = "";
                lblUpdateError.Text = Resources.General.UpdateFaild;
            }
        }
    }

    protected void btnInternal_Click(object sender, EventArgs e)
    {
        Int64 ProviderId = Convert.ToInt64(txtProviderId.Text.Trim());
        txtCarId.Text = CE.Global.General.GetCarId(Server.HtmlEncode(txtSearch.Text).Trim());
        Int64 RefId = Convert.ToInt64(txtCarId.Text.Trim());
        string InsType = "CI";
        string _fileName = "FileName";
        string Language = ddlExcelLanguage.Text;

        string _downloaddate = " : " + dateTimeNow.Day.ToString("00") + "/" + dateTimeNow.Month.ToString("00") + "/" + dateTimeNow.Year + " " + dateTimeNow.ToShortTimeString();  //+DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00") + " " + DateTime.Now.Ticks;
        if (InsType == "CI")
        {
            lblInternalExcel.Text = "";
            if (ProviderId == 11)
            {
                lblInternalExcel.Text = GenerateCIHTML_AZCp(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 12)
            {
                lblInternalExcel.Text = GenerateCIHTML_MSIG(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 16)
            {
                lblInternalExcel.Text = GenerateCIHTML_AXA(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 29)
            {
                lblInternalExcel.Text = GenerateCIHTML_LMG(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 31)
            {
                lblInternalExcel.Text = GenerateCIHTML_Chartis(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 32)
            {
                lblInternalExcel.Text = GenerateCIHTML_BKI(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 33)
            {
                lblInternalExcel.Text = GenerateCIHTML_MTI(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 41)
            {
                lblInternalExcel.Text = GenerateCIHTML_Kurnia(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
            else if (ProviderId == 46)
            {
                lblInternalExcel.Text = GenerateCIHTML_TMS(RefId, InsType, Language);
                _fileName = GetReferenceNumber(RefId.ToString(), ProviderId.ToString()) + "_" + dateTimeNow.Day.ToString("00") + "-" + dateTimeNow.Month.ToString("00") + "-" + dateTimeNow.Year;
                StringBuilder strText = new StringBuilder("");
                ExportGridView(_fileName, lblInternalExcel);
            }
        }
    }

    public void LoadApplicationDetails()
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetCarApplicationDetails(Convert.ToInt64(txtCarId.Text.Trim()));
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {
            lblSearchMessage.Text = "";
            #region Assign Values
            lblUpRefNo.Text = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            lblUpApplicantName.Text = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (lblLangOption.Text == "1")
            {
                lblUpInsurer.Text = _dsApplication.Tables[0].Rows[0]["InsurerNameTH"].ToString();
            }
            else
            {
                lblUpInsurer.Text = _dsApplication.Tables[0].Rows[0]["InsurerName"].ToString();
            }
            lblUpPlanName.Text = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            lblUpPremium.Text = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            txtProviderId.Text = _dsApplication.Tables[0].Rows[0]["ProviderCompanyId"].ToString();
            txtUserId.Text = _dsApplication.Tables[0].Rows[0]["RefCEUserId"].ToString();
            txtOrderRefNo.Text = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            txtSubmitedAgentId.Text = _dsApplication.Tables[0].Rows[0]["AgentId"].ToString();
            txtSubmitedType.Text = _dsApplication.Tables[0].Rows[0]["SubmitType"].ToString();
            txtCancelStatus.Text = _dsApplication.Tables[0].Rows[0]["CancelStatus"].ToString();
            divCar.Visible = true;
           
            #endregion
        }
        else
        {
            lblSearchMessage.Text = Resources.General.CheckRefNo;
            ClearFields();
        }
    }

    public void GetPaymentDetails()
    {
        MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
        string _spName = "sprocCarInsuranceTHCompletedUserSelectItem";
        SortedList _spara = new SortedList();
        _spara.Add("@CarId", Convert.ToInt64(txtCarId.Text.Trim()));
        _spara.Add("@ProviderCompanyId", Convert.ToInt64(txtProviderId.Text));
        DataSet _dsPaymentDetails = new DataSet();
        _dsPaymentDetails = _db.GetDataSet(_spName, _spara);
        if (_dsPaymentDetails != null && _dsPaymentDetails.Tables.Count > 0)
        {
            if (_dsPaymentDetails.Tables[0].Rows.Count > 0)
            {
                txtCCReceiptNo.Text = "";
                lblUpPaymentType.Text = _dsPaymentDetails.Tables[0].Rows[0]["Payment"].ToString();
                lblUpPaymentStatus.Text = _dsPaymentDetails.Tables[0].Rows[0]["PaymentGateWayStatus"].ToString();
                txtCCReceiptNo.Text = _dsPaymentDetails.Tables[0].Rows[0]["ReceiptNo"].ToString();
                if (lblUpPaymentStatus.Text == "SUCCEEDED" && txtCancelStatus.Text == "0")
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Proceed, "PROC"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.CancelRejectApplication, "CRAP"));
                    if (lblUpPaymentType.Text == "CC" && txtCCReceiptNo.Text.Trim().Length == 0)
                    {
                        ddlOption.Items.Clear();
                        ddlOption.Items.Add(new ListItem("Please Select", "0"));
                        ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Continue, "CONT"));
                        ddlOption.Items.Add(new ListItem(Resources.CarInsurance.CancelRejectApplication, "CRAP"));
                    }
                }
                else if (lblUpPaymentType.Text == "CC" && lblUpPaymentStatus.Text != "SUCCEEDED" && txtCancelStatus.Text == "0")
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.TryAgainOnlineBKK, "TABP"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.IPayReferenceNo, "IPAY"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.BankInChangePaymentType, "BTPT"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.CancelRejectApplication, "CRAP"));
                }
                else if (lblUpPaymentType.Text == "BT" && txtCancelStatus.Text == "0")
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Continue, "CONT"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.CreditCardChangePaymentType, "CCPT"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.CancelRejectApplication, "CRAP"));
                }
                else if (txtCancelStatus.Text == "1")
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Retrieve, "RTRV"));
                }
                ddlOption_SelectedIndexChanged(null, null);
            }
            else
            {
                ddlOption_SelectedIndexChanged(null, null);
            }
        }
        else
        {
            ddlOption_SelectedIndexChanged(null, null);
        }
    }

    public void GetCarMoreDetails()
    {
        txtTitle.Text = "";
        txtDispalcement.Text = "";
        txtWeight.Text = "";
        
        txtEngineNumber.Text = "";
        txtChassisNumber.Text = "";
        MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
        string _spName = "sprocCarMoreDetailSelectSingleItem";
        SortedList _spara = new SortedList();
        _spara.Add("@CarId", Convert.ToInt64(txtCarId.Text.Trim()));
        _spara.Add("@RefCEUserId", Convert.ToInt64(txtUserId.Text));
        _spara.Add("@ProviderCompanyId", Convert.ToInt64(txtProviderId.Text));
        DataSet _dsCarMoreDetails = new DataSet();
        _dsCarMoreDetails = _db.GetDataSet(_spName, _spara);
        if (_dsCarMoreDetails != null && _dsCarMoreDetails.Tables.Count > 0)
        {
            if (_dsCarMoreDetails.Tables[0].Rows.Count > 0)
            {
                txtTitle.Text = _dsCarMoreDetails.Tables[0].Rows[0]["Title"].ToString();
                txtDispalcement.Text = _dsCarMoreDetails.Tables[0].Rows[0]["Dispalcement"].ToString();
                txtWeight.Text = _dsCarMoreDetails.Tables[0].Rows[0]["VehicleWeight"].ToString();
                txtNumberofSeat.Text = _dsCarMoreDetails.Tables[0].Rows[0]["NumberofSeat"].ToString();
                
                txtEngineNumber.Text = _dsCarMoreDetails.Tables[0].Rows[0]["EngineNumber"].ToString();
                txtChassisNumber.Text = _dsCarMoreDetails.Tables[0].Rows[0]["ChassisNumber"].ToString();
                if (_dsCarMoreDetails.Tables.Count > 1)
                {
                    if (_dsCarMoreDetails.Tables[1].Rows.Count > 0)
                    {
                        txtReceiptNo.Text = _dsCarMoreDetails.Tables[1].Rows[0]["Info8"].ToString();
                        if (txtReceiptNo.Text.Trim() != "")
                        {
                            GetCarDocumentDetails();
                        }
                    }
                }
            }
        }
    }

    public void ClearFields()
    {
        pnlMessage.Visible = false;
        divCar.Visible = false;
        
        pnlDetails.Visible = false;
        btnUpdate.Enabled = true;
        UploadButton.Enabled = true;
        lblUpdateMessage.Text = "";
        lblUpdateError.Text = "";
        txtCarId.Text = "";
        lblUpRefNo.Text = "";
        lblUpApplicantName.Text = "";
        lblUpInsurer.Text = "";
        lblUpPlanName.Text = "";
        lblUpPremium.Text = "";
        txtProviderId.Text = "";
        txtUserId.Text = "";
    }

    public string GetReferenceNumber(string Number, string ProviderId)
    {
        string convertno = CE.Global.General.GetRefNumber(Convert.ToInt64(Number.ToString()));
        string _RefNo = "";
        if (ProviderId == "11")
        {
            _RefNo = "AZC" + convertno.ToString();
        }
        else if (ProviderId == "12")
        {
            _RefNo = "MSI" + convertno.ToString();
        }
        else if (ProviderId == "16")
        {
            _RefNo = "AXA" + convertno.ToString();
        }
        else if (ProviderId == "29")
        {
            _RefNo = "LMG" + convertno.ToString();
        }
        else if (ProviderId == "31")
        {
            _RefNo = "CTS" + convertno.ToString();
        }
        else if (ProviderId == "32")
        {
            _RefNo = "BKI" + convertno.ToString();
        }
        else if (ProviderId == "33")
        {
            _RefNo = "MTI" + convertno.ToString();
        }
        else if (ProviderId == "41")
        {
            _RefNo = "KUR" + convertno.ToString();
        }
        else if (ProviderId == "46")
        {
            _RefNo = "TMS" + convertno.ToString();
        }
        return _RefNo;
    }

    private string GetExcelFilePath(Int64 ProviderCompanyId, string QuoteRefNo)
    {
        string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
        string _provider = GetProvider(ProviderCompanyId);
        CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
        string _currentMonth = dateTimeNow.ToString("yyyyMMM");
        string _todaydate = dateTimeNow.ToString("yyyyMMMdd");
        _filePath += "exceloutput\\" + _provider + "\\";
        if (!_myIO.CheckDirectory(_filePath + _currentMonth))
        {
            if (_myIO.CreateDirectory(_filePath, _currentMonth))
            {
                _filePath += _currentMonth + "\\";
            }
        }
        else
        {
            _filePath += _currentMonth + "\\";
        }

        if (!_myIO.CheckDirectory(_filePath + _todaydate))
        {
            if (_myIO.CreateDirectory(_filePath, _todaydate))
            {
                _filePath += _todaydate + "\\";
            }
        }
        else
        {
            _filePath += _todaydate + "\\";
        }

        if (!_myIO.CheckDirectory(_filePath + QuoteRefNo))
        {
            if (_myIO.CreateDirectory(_filePath, QuoteRefNo))
            {
                _filePath += QuoteRefNo + "\\";
            }
        }
        else
        {
            _filePath += QuoteRefNo + "\\";
        }
        return _filePath;
    }

    private string GetPdfFilePath(Int64 ProviderCompanyId, string QuoteRefNo)
    {
        string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
        string _provider = GetProvider(ProviderCompanyId);
        string _currentMonth = dateTimeNow.ToString("yyyyMMM");
        string _todaydate = dateTimeNow.ToString("yyyyMMMdd");
        _filePath += "upload\\" + _provider + "\\";
        CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
        if (!_myIO.CheckDirectory(_filePath + _currentMonth))
        {
            if (_myIO.CreateDirectory(_filePath, _currentMonth))
            {
                _filePath += _currentMonth + "\\";
            }
        }
        else
        {
            _filePath += _currentMonth + "\\";
        }

        if (!_myIO.CheckDirectory(_filePath + _todaydate))
        {
            if (_myIO.CreateDirectory(_filePath, _todaydate))
            {
                _filePath += _todaydate + "\\";
            }
        }
        else
        {
            _filePath += _todaydate + "\\";
        }

        if (!_myIO.CheckDirectory(_filePath + QuoteRefNo))
        {
            if (_myIO.CreateDirectory(_filePath, QuoteRefNo))
            {
                _filePath += QuoteRefNo + "\\";
            }
        }
        else
        {
            _filePath += QuoteRefNo + "\\";
        }
        return _filePath;
    }

    private string GetExcelFilePathOld(Int64 ProviderCompanyId)
    {
        string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
        string _provider = GetProvider(ProviderCompanyId);
        _filePath += "exceloutput\\" + _provider + "\\";
        CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
        string _todaydate = dateTimeNow.ToString("yyyyMMMdd");
        if (!_myIO.CheckDirectory(_filePath + _todaydate))
        {
            if (_myIO.CreateDirectory(_filePath, _todaydate))
            {
                _filePath += _todaydate + "\\";
            }
        }
        else
        {
            _filePath += _todaydate + "\\";
        }

        return _filePath;
    }

    private string GetPdfFilePathOld(Int64 ProviderCompanyId)
    {
        string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("FileOutputPath").ToString();
        string _provider = GetProvider(ProviderCompanyId);
        string _todaydate = dateTimeNow.ToString("yyyyMMMdd");
        _filePath += "upload\\" + _provider + "\\";
        CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
        if (!_myIO.CheckDirectory(_filePath + _todaydate))
        {
            if (_myIO.CreateDirectory(_filePath, _todaydate))
            {
                _filePath += _todaydate + "\\";
            }
        }
        else
        {
            _filePath += _todaydate + "\\";
        }

        return _filePath;
    }

    private string GetProvider(Int64 ProviderCompanyId)
    {
        string _result = "";
        if (ProviderCompanyId == 11)
        {
            _result = "azcp";
        }
        else if (ProviderCompanyId == 12)
        {
            _result = "msig";
        }
        else if (ProviderCompanyId == 16)
        {
            _result = "axa";
        }
        else if (ProviderCompanyId == 29)
        {
            _result = "lmg";
        }
        else if (ProviderCompanyId == 31)
        {
            _result = "cts";
        }
        else if (ProviderCompanyId == 32)
        {
            _result = "bki";
        }
        else if (ProviderCompanyId == 33)
        {
            _result = "mti";
        }
        else if (ProviderCompanyId == 41)
        {
            _result = "kur";
        }
        else if (ProviderCompanyId == 46)
        {
            _result = "tms";
        }
        return _result;
    }

    private string GetProviderName(Int64 ProviderCompanyId)
    {
        string _result = "";
        if (ProviderCompanyId == 11)
        {
            _result = "อลิอันซ์ ซี.พี. ประกันภัย";
        }
        else if (ProviderCompanyId == 12)
        {
            _result = "เอ็ม เอส ไอ จี ประกันภัย";
        }
        else if (ProviderCompanyId == 16)
        {
            _result = "แอกซ่า ประกันภัย";
        }
        else if (ProviderCompanyId == 29)
        {
            _result = "แอลเอ็มจี ประกันภัย";
        }
        else if (ProviderCompanyId == 31)
        {
            _result = "นิวแฮมพ์เชอร์ อินชัวรันส์";
        }
        else if (ProviderCompanyId == 32)
        {
            _result = "กรุงเทพประกันภัย";
        }
        else if (ProviderCompanyId == 33)
        {
            _result = "เมืองไทยประกันภัย";
        }
        else if (ProviderCompanyId == 41)
        {
            _result = "คูเนีย ประกันภัย";
        }
        else if (ProviderCompanyId == 46)
        {
            _result = "โตเกียวมารีนศรีเมือง";
        }
        return _result;
    }

    private string GetProviderBrokerCode(Int64 ProviderCompanyId)
    {
        string _result = "";
        if (ProviderCompanyId == 11)
        {
            _result = "001600";
        }
        else if (ProviderCompanyId == 12)
        {
            _result = "AFM1012";
        }
        else if (ProviderCompanyId == 16)
        {
            _result = "BB115";
        }
        else if (ProviderCompanyId == 29)
        {
            _result = "BR00619";
        }
        else if (ProviderCompanyId == 31)
        {
            _result = "002851000";
        }
        else if (ProviderCompanyId == 32)
        {
            _result = "641100";
        }
        else if (ProviderCompanyId == 33)
        {
            _result = "74000352";
        }
        else if (ProviderCompanyId == 41)
        {
            _result = "198700-00";
        }
        else if (ProviderCompanyId == 46)
        {
            _result = "10233002";
        }
        return _result;
    }

    private string GetProviderMail(Int64 ProviderCompanyId)
    {
        string _result = "";
        if (ProviderCompanyId == 11)
        {
            _result = "TO_AZCP";
        }
        else if (ProviderCompanyId == 12)
        {
            _result = "TO_MSIG";
        }
        else if (ProviderCompanyId == 16)
        {
            _result = "TO_AXA";
        }
        else if (ProviderCompanyId == 29)
        {
            _result = "TO_LMG";
        }
        else if (ProviderCompanyId == 31)
        {
            _result = "TO_CTS";
        }
        else if (ProviderCompanyId == 32)
        {
            _result = "TO_BKI";
        }
        else if (ProviderCompanyId == 33)
        {
            _result = "TO_MTI";
        }
        else if (ProviderCompanyId == 41)
        {
            _result = "TO_KUR";
        }
        else if (ProviderCompanyId == 46)
        {
            _result = "TO_TMS";
        }
        return _result;
    }

    private string GenerateExcel(Int64 ProviderCompanyId, Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _result = "";
        if (ProviderCompanyId == 11)
        {
            _result = GenerateCIHTML_AZCp(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 12)
        {
            _result = GenerateCIHTML_MSIG(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 16)
        {
            _result = GenerateCIHTML_AXA(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 29)
        {
            _result = GenerateCIHTML_LMG(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 31)
        {
            _result = GenerateCIHTML_Chartis(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 32)
        {
            _result = GenerateCIHTML_BKI(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 33)
        {
            _result = GenerateCIHTML_MTI(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 41)
        {
            _result = GenerateCIHTML_Kurnia(RefId, InsType, FilePath, FileName);
        }
        else if (ProviderCompanyId == 46)
        {
            _result = GenerateCIHTML_TMS(RefId, InsType, FilePath, FileName);
        }
        return _result;
    }

    public string GenerateCIHTML_AXA(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetAXAApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;

            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            //EngineNumber = _dsApplication.Tables[0].Rows[0]["EngineNumber"].ToString();
            //ChassisNumber = _dsApplication.Tables[0].Rows[0]["ChassisNumber"].ToString();
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>AXA Insurance</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
           

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_AZCp(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetAZCpApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>Allianz Insurance</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
            

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_BKI(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetBKIApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            //EngineNumber = _dsApplication.Tables[0].Rows[0]["EngineNumber"].ToString();
            //ChassisNumber = _dsApplication.Tables[0].Rows[0]["ChassisNumber"].ToString();
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>Bangkok Insurance</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
            

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_Chartis(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetChartisApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>Chartis Insurance</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
           

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_LMG(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetLMGApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;

            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = ""; CarPlate = "";
            EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = ""; QuoteRefNo = "";
            Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = ""; PresentAddress = ""; SubDistrict = "";
            District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }


            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>LMG Insurance</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
            

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_MSIG(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetMSIGApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>MSIG Insurance</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
          

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_MTI(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetMTIApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>เมืองไทยประกันภัย</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
            

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_Kurnia(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetKurniaApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>คูเนียประกันภัย</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
           

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    public string GenerateCIHTML_TMS(Int64 RefId, string InsType, string FilePath, string FileName)
    {
        string _returnFilePath = "";
        Label lblContent = new Label();
        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td colspan='2'><h3>ประกันภัยรถยนต์ - แบบฟอร์ม</h3></td></tr></table>");
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetTMSApplication(RefId, InsType, 0);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
            _html += "<tr><td width='20%' align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
            _html += "<tr><td width='20%' align='left'><b>คำนำหน้า</b></td><td width='80%' align='left'>" + Title + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ชื่อผู้ทำประกัน</b></td><td width='80%' align='left'>" + Name + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' width='80%' align='left'>" + IdentificationNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + DOB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เพศ</b></td><td width='80%' align='left'>" + Gender + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>อาชีพ</b></td><td width='80%' align='left'>" + Occupation + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' width='80%' align='left'>" + ContactNo + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td width='80%' align='left'>" + PresentAddress + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แขวง/ตำบล</b></td><td width='80%' align='left'>" + SubDistrict + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>เขต/อำเภอ</b></td><td width='80%' align='left'>" + District + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัด</b></td><td width='80%' align='left'>" + Province + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รหัสไปรษณีย์</b></td><td width='80%' align='left'>" + PostalCode + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกัน</b></td><td width='80%' align='left'>โตเกียวมารีนศรีเมือง</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>แพกเก็จ</b></td><td width='80%' align='left'>" + CoverType + "</td></tr>";

            _html += "<tr><td width='20%' align='left'><b>ระบุผู้ขับขี่</b></td><td width='80%' align='left'>" + AddDrivers + "</td></tr>";
            if (AddDrivers == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวนผู้ขับขี่</b></td><td width='80%' align='left'>" + NoOfDriver + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 0)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td width='80%' align='left'>" + DriverLicenseNo1 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 1)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td width='80%' align='left'>" + DriverLicenseNo2 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 2)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td width='80%' align='left'>" + DriverLicenseNo3 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 3)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td width='80%' align='left'>" + DriverLicenseNo4 + "</td></tr>";
            }
            if (Convert.ToInt16(NoOfDriver) > 4)
            {
                _html += "<tr><td width='20%' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td width='80%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                _html += "<tr><td width='20%' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td width='80%' align='left'>" + DriverLicenseNo5 + "</td></tr>";
            }

            _html += "<tr><td width='20%' align='left'><b>ประเภทประกัน</b></td><td width='80%' align='left'>" + InsuranceType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทอู่</b></td><td width='80%' align='left'>" + GarageType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ปีของรถ</b></td><td width='80%' align='left'>" + CarModelYear + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>รุ่น</b></td><td width='80%' align='left'>" + CarMakeModel + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ขนาด (cc.)</b></td><td width='80%' align='left'>" + Displacement + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จำนวนที่นั่ง</b></td><td width='80%' align='left'>" + NumberofSeat + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ผู้รับผลประโยชน์</b></td><td width='80%' align='left'>" + Beneficiary + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ประเภทรถ</b></td><td width='80%' align='left'>" + VehicleType + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + SumInsured + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ส่วนลด NCB</b></td><td width='80%' align='left'>" + NCB + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td width='80%' align='left'>" + CurrentInsurer + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>ทะเบียนรถ</b></td><td width='80%' align='left'>" + CarPlate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td width='80%' align='left'>" + ProvinceRegistration + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลขเครื่อง</b></td><td width='80%' align='left'>" + EngineNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>หมายเลข Chassis</b></td><td width='80%' align='left'>" + ChassisNumber + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td width='80%' align='left'>" + Accessories + "</td></tr>";
            if (Accessories == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td width='80%' align='left'>" + ModifyCost + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
            _html += "<tr><td width='20%'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' width='80%' align='left'>" + CommencementDate + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>พ.ร.บ.</b></td><td width='80%' align='left'>" + CTPL + "</td></tr>";
            if (CTPL == "Yes")
            {
                _html += "<tr><td width='20%' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + CTPLAmount + "</td></tr>";
            }
            _html += "<tr><td width='20%' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' width='80%' align='left'>" + TotalPremium + "</td></tr>";
            _html += "<tr><td width='20%' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' width='80%' align='left'>" + ApplicationDate + "</td></tr>";
            
            _html += "</table></body></html>";
            #endregion

            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = lblContent.Text.ToString();
           

            myio.WriteNewFile(FilePath, FileName + ".xls", filecontent);
            _returnFilePath = FilePath + FileName + ".xls";
        }
        return _returnFilePath;
    }

    protected void btnPDFDownload1_Click(object sender, EventArgs e)
    {
        Response.Redirect(hplPDFDownLoad1.NavigateUrl);
    }

    protected void btnPDFDownload2_Click(object sender, EventArgs e)
    {
        Response.Redirect(hplPDFDownLoad2.NavigateUrl);
    }

    protected void btnPDFDownload3_Click(object sender, EventArgs e)
    {
        Response.Redirect(hplPDFDownLoad3.NavigateUrl);
    }

    protected void btnExcelDownload_Click(object sender, EventArgs e)
    {
        Response.Redirect(hplExcelDownLoad.NavigateUrl);
    }

    public void GetCarDocumentDetails()
    {
        MyIO _myIO = new MyIO();
        MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
        string _spName = "sprocCarDocumentDetailSelectItemListbyCarId";
        SortedList _spara = new SortedList();
        _spara.Add("@CarId", Convert.ToInt64(txtCarId.Text));
        _spara.Add("@RefCEUserId", Convert.ToInt64(txtUserId.Text));
        _spara.Add("@ProviderCompanyId", Convert.ToInt64(txtProviderId.Text));
        DataSet _dsCarDocumentDetails = new DataSet();
        _dsCarDocumentDetails = _db.GetDataSet(_spName, _spara);
        if (_dsCarDocumentDetails != null && _dsCarDocumentDetails.Tables.Count > 0)
        {
            if (_dsCarDocumentDetails.Tables[0].Rows.Count > 0)
            {
                hplPDFDownLoad1.NavigateUrl = "download/handler.ashx?fileName=test.pdf&carId=" + txtCarId.Text.Trim() + "&userId=" + txtUserId.Text.Trim() + "&providerId=" + txtProviderId.Text.Trim() + "&fileCount=0";
                hplPDFDownLoad1.Visible = true;

                if (_dsCarDocumentDetails.Tables[0].Rows.Count > 1)
                {
                    hplPDFDownLoad2.NavigateUrl = "download/handler.ashx?fileName=test.pdf&carId=" + txtCarId.Text.Trim() + "&userId=" + txtUserId.Text.Trim() + "&providerId=" + txtProviderId.Text.Trim() + "&fileCount=1";
                    hplPDFDownLoad2.Visible = true;
                }

                if (_dsCarDocumentDetails.Tables[0].Rows.Count > 2)
                {
                    hplPDFDownLoad3.NavigateUrl = "download/handler.ashx?fileName=test.pdf&carId=" + txtCarId.Text.Trim() + "&userId=" + txtUserId.Text.Trim() + "&providerId=" + txtProviderId.Text.Trim() + "&fileCount=2";
                    hplPDFDownLoad3.Visible = true;
                }
            }
            else
            {
                hplPDFDownLoad1.Visible = false;
                hplPDFDownLoad2.Visible = false;
                hplPDFDownLoad3.Visible = false;
            }
        }
        else
        {
            hplPDFDownLoad1.Visible = false;
            hplPDFDownLoad2.Visible = false;
            hplPDFDownLoad3.Visible = false;
        }
        if (_dsCarDocumentDetails != null && _dsCarDocumentDetails.Tables.Count > 1)
        {
            if (_dsCarDocumentDetails.Tables[1].Rows.Count > 0)
            {
                hplExcelDownLoad.NavigateUrl = "download/handler.ashx?fileName=test.xls&carId=" + txtCarId.Text.Trim() + "&userId=" + txtUserId.Text.Trim() + "&providerId=" + txtProviderId.Text.Trim();
                hplExcelDownLoad.Visible = true;
            }
            else
            {
                hplExcelDownLoad.Visible = false;
            }
        }
        else
        {
            hplExcelDownLoad.Visible = false;
        }
        if (_dsCarDocumentDetails != null && _dsCarDocumentDetails.Tables.Count > 1)
        {
            if (_dsCarDocumentDetails.Tables[0].Rows.Count > 0 && _dsCarDocumentDetails.Tables[1].Rows.Count > 0)
            {
                ddlOption.Items.Clear();
                ddlOption.Items.Add(new ListItem("Please Select", "0"));
                ddlOption.Items.Add(new ListItem(Resources.CarInsurance.CancelRejectApplication, "CRAP"));
                pnlMessage.Visible = true;
            }
        }
    }

    public string GenerateCIHTML_AXA(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetAXAApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;

            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td align='left'>AXA Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00' align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM' align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>AXA Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_AZCp(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetAZCpApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'>Allianz Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>Allianz Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_BKI(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetBKIApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td  style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'>Bangkok Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>Bangkok Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_Chartis(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetChartisApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'>Chartis Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>Chartis Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_LMG(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetLMGApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;

            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = ""; CarPlate = "";
            EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = ""; QuoteRefNo = "";
            Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = ""; PresentAddress = ""; SubDistrict = "";
            District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
           
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }


            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'>LMG Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                   _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>LMG Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_MSIG(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetMSIGApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";

            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();

            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'>MSIG Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>MSIG Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_MTI(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetMTIApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'>Muang Thai Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>เมืองไทยประกันภัย</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_Kurnia(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetKurniaApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
            
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'>Kurnia Insurance</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>คูเนียประกันภัย</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public string GenerateCIHTML_TMS(Int64 RefId, string InsType, string Language)
    {
        DataSet _dsApplication = new DataSet();
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _dsApplication = _proposalsummarydb.GetTMSApplication(RefId, InsType, 1);
        string _html = "";
        if (_dsApplication.Tables[0].Rows.Count > 0)
        {

            #region Variable Declaration

            string Title, Name, IdentificationNo, ContactNo, Email, DOB, Occupation, Gender, NoOfDriver, CurrentInsurer, InsuranceType, GarageType, CarModelYear, CarMakeModel;
            string Accessories, ModifyCost, VehicleType, SumInsured, NCB, ProvinceRegistration, AnyClaims, AddDrivers, CommencementDate, OfficePhoneNo, LicenseNo;
            string CarPlate, EngineNumber, ChassisNumber, CTPL, CTPLAmount, TotalPremium, PaymentType, OrderRefNo, QuoteRefNo, Payment, ApplicationDate;
            string ModifiedDate, CoverType, Beneficiary, PresentAddress, SubDistrict, District, Province, PostalCode, Displacement, VehicleWeight, NumberofSeat;


            Title = ""; Name = ""; IdentificationNo = ""; ContactNo = ""; Email = ""; DOB = ""; Occupation = ""; Gender = ""; NoOfDriver = "0"; CurrentInsurer = ""; InsuranceType = "";
            GarageType = ""; CarModelYear = ""; CarMakeModel = ""; Accessories = "No"; ModifyCost = ""; VehicleType = ""; SumInsured = ""; NCB = "";
            ProvinceRegistration = ""; AnyClaims = "No"; AddDrivers = "No"; CommencementDate = ""; OfficePhoneNo = ""; LicenseNo = "";
            CarPlate = ""; EngineNumber = ""; ChassisNumber = ""; CTPL = ""; CTPLAmount = ""; TotalPremium = ""; PaymentType = ""; OrderRefNo = "";
            QuoteRefNo = ""; Payment = ""; ApplicationDate = ""; ModifiedDate = ""; CoverType = ""; Beneficiary = "";
            PresentAddress = ""; SubDistrict = ""; District = ""; Province = ""; PostalCode = ""; Displacement = ""; VehicleWeight = ""; NumberofSeat = "";
            //For Driver
            string DriverName1, DriverDOB1, DriverAge1, DriverLicenseNo1, DriverName2, DriverDOB2, DriverAge2, DriverLicenseNo2;
            string DriverName3, DriverDOB3, DriverAge3, DriverLicenseNo3, DriverName4, DriverDOB4, DriverAge4, DriverLicenseNo4;
            string DriverName5, DriverDOB5, DriverAge5, DriverLicenseNo5;

            DriverName1 = ""; DriverDOB1 = ""; DriverAge1 = ""; DriverLicenseNo1 = "";
            DriverName2 = ""; DriverDOB2 = ""; DriverAge2 = ""; DriverLicenseNo2 = "";
            DriverName3 = ""; DriverDOB3 = ""; DriverAge3 = ""; DriverLicenseNo3 = "";
            DriverName4 = ""; DriverDOB4 = ""; DriverAge4 = ""; DriverLicenseNo4 = "";
            DriverName5 = ""; DriverDOB5 = ""; DriverAge5 = ""; DriverLicenseNo5 = "";

            #endregion

            #region Assign Values

            Name = _dsApplication.Tables[0].Rows[0]["Name"].ToString();
            if (_dsApplication.Tables[0].Rows[0]["IdentificationNo"] != null)
            {
                IdentificationNo = _dsApplication.Tables[0].Rows[0]["IdentificationNo"].ToString();
            }
            ContactNo = _dsApplication.Tables[0].Rows[0]["ContactNo"].ToString();
            Email = _dsApplication.Tables[0].Rows[0]["Email"].ToString();
            DOB = _dsApplication.Tables[0].Rows[0]["DOB"].ToString();
            Occupation = _dsApplication.Tables[0].Rows[0]["Occupation"].ToString();
            Gender = _dsApplication.Tables[0].Rows[0]["Gender"].ToString();
            NoOfDriver = _dsApplication.Tables[0].Rows[0]["NoOfDriver"].ToString();
            CurrentInsurer = _dsApplication.Tables[0].Rows[0]["CurrentInsurer"].ToString();
            InsuranceType = _dsApplication.Tables[0].Rows[0]["InsuranceType"].ToString();
            GarageType = _dsApplication.Tables[0].Rows[0]["GarageType"].ToString();
            CarModelYear = _dsApplication.Tables[0].Rows[0]["CarModelYear"].ToString();
            CarMakeModel = _dsApplication.Tables[0].Rows[0]["CarMakeModel"].ToString();
            Accessories = _dsApplication.Tables[0].Rows[0]["Accessories"].ToString();
            ModifyCost = _dsApplication.Tables[0].Rows[0]["ModifyCost"].ToString();
            VehicleType = _dsApplication.Tables[0].Rows[0]["VehicleType"].ToString();
            SumInsured = _dsApplication.Tables[0].Rows[0]["SumInsured"].ToString();
            ProvinceRegistration = _dsApplication.Tables[0].Rows[0]["ProvinceRegistration"].ToString();
            AnyClaims = _dsApplication.Tables[0].Rows[0]["AnyClaims"].ToString();
            AddDrivers = _dsApplication.Tables[0].Rows[0]["AddDrivers"].ToString();
            CommencementDate = _dsApplication.Tables[0].Rows[0]["CommencementDate"].ToString();
            OfficePhoneNo = _dsApplication.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            LicenseNo = _dsApplication.Tables[0].Rows[0]["LicenseNo"].ToString();
            CarPlate = _dsApplication.Tables[0].Rows[0]["CarPlate"].ToString();
          
            CTPL = _dsApplication.Tables[0].Rows[0]["CTPL"].ToString();
            CTPLAmount = _dsApplication.Tables[0].Rows[0]["CTPLAmount"].ToString();
            TotalPremium = _dsApplication.Tables[0].Rows[0]["TotalPremium"].ToString();
            PaymentType = _dsApplication.Tables[0].Rows[0]["PaymentType"].ToString();
            OrderRefNo = _dsApplication.Tables[0].Rows[0]["OrderRefNo"].ToString();
            QuoteRefNo = _dsApplication.Tables[0].Rows[0]["QuoteRefNo"].ToString();
            Payment = _dsApplication.Tables[0].Rows[0]["Payment"].ToString();
            ApplicationDate = _dsApplication.Tables[0].Rows[0]["ApplicationDate"].ToString();
            ModifiedDate = _dsApplication.Tables[0].Rows[0]["ModifiedDate"].ToString();
            CoverType = _dsApplication.Tables[0].Rows[0]["CoverTypeDesc"].ToString();
            NCB = _dsApplication.Tables[0].Rows[0]["NCB"].ToString();
            Beneficiary = _dsApplication.Tables[0].Rows[0]["BeneficiaryName"].ToString();
            PresentAddress = _dsApplication.Tables[0].Rows[0]["PresentAddress"].ToString();
            SubDistrict = _dsApplication.Tables[0].Rows[0]["SubDistrict"].ToString();
            District = _dsApplication.Tables[0].Rows[0]["District"].ToString();
            Province = _dsApplication.Tables[0].Rows[0]["Province"].ToString();
            PostalCode = _dsApplication.Tables[0].Rows[0]["PostalCode"].ToString();
            if (AddDrivers == "Yes")
            {
                if (_dsApplication.Tables[1].Rows.Count > 0)
                {
                    if (Convert.ToInt16(NoOfDriver) > 0)
                    {
                        DriverName1 = _dsApplication.Tables[1].Rows[0]["DriverName"].ToString();
                        DriverDOB1 = _dsApplication.Tables[1].Rows[0]["DOB"].ToString();
                        DriverAge1 = _dsApplication.Tables[1].Rows[0]["Age"].ToString();
                        DriverLicenseNo1 = _dsApplication.Tables[1].Rows[0]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 1)
                    {

                        DriverName2 = _dsApplication.Tables[1].Rows[1]["DriverName"].ToString();
                        DriverDOB2 = _dsApplication.Tables[1].Rows[1]["DOB"].ToString();
                        DriverAge2 = _dsApplication.Tables[1].Rows[1]["Age"].ToString();
                        DriverLicenseNo2 = _dsApplication.Tables[1].Rows[1]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 2)
                    {
                        DriverName3 = _dsApplication.Tables[1].Rows[2]["DriverName"].ToString();
                        DriverDOB3 = _dsApplication.Tables[1].Rows[2]["DOB"].ToString();
                        DriverAge3 = _dsApplication.Tables[1].Rows[2]["Age"].ToString();
                        DriverLicenseNo3 = _dsApplication.Tables[1].Rows[2]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 3)
                    {
                        DriverName4 = _dsApplication.Tables[1].Rows[3]["DriverName"].ToString();
                        DriverDOB4 = _dsApplication.Tables[1].Rows[3]["DOB"].ToString();
                        DriverAge4 = _dsApplication.Tables[1].Rows[3]["Age"].ToString();
                        DriverLicenseNo4 = _dsApplication.Tables[1].Rows[3]["DrivingLicenseNumber"].ToString();
                    }
                    if (Convert.ToInt16(NoOfDriver) > 4)
                    {
                        DriverName5 = _dsApplication.Tables[1].Rows[4]["DriverName"].ToString();
                        DriverDOB5 = _dsApplication.Tables[1].Rows[4]["DOB"].ToString();
                        DriverAge5 = _dsApplication.Tables[1].Rows[4]["Age"].ToString();
                        DriverLicenseNo5 = _dsApplication.Tables[1].Rows[4]["DrivingLicenseNumber"].ToString();
                    }
                }
            }

            if (_dsApplication.Tables.Count > 2 && _dsApplication.Tables[2].Rows.Count > 0)
            {
                Title = _dsApplication.Tables[2].Rows[0]["Title"].ToString();
                Displacement = _dsApplication.Tables[2].Rows[0]["Dispalcement"].ToString();
                VehicleWeight = _dsApplication.Tables[2].Rows[0]["VehicleWeight"].ToString();
                NumberofSeat = _dsApplication.Tables[2].Rows[0]["NumberofSeat"].ToString();
                EngineNumber = _dsApplication.Tables[2].Rows[0]["EngineNumber"].ToString();
                ChassisNumber = _dsApplication.Tables[2].Rows[0]["ChassisNumber"].ToString();
            }

            #endregion

            #region Generate Excel File
            if (Language == "EN")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>Applicant Details</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>Title</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Applicant Name</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>IdentificationNo</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>DOB</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gender</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Occupation</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ContactNo</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PresentAddress</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SubDistrict</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>District</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Province</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>PostalCode</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Insurer</b></td><td  align='left'> Tokio marine Srimuang</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Package</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>Specify Named Driver</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Number Of Named Driver</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 1st Driver</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 1st Driver</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 2nd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 2nd Driver</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 3rd Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 3rd Driver</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 4th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 4th Driver</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>DOB of 5th Driver</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>Driver License of 5th Driver</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>InsuranceType</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>GarageType</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarModelYear</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CarMakeModel</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Displacement (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Gross Vehicle Weight (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Number of seat</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Beneficiary</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>VehicleType</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>SumInsured</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CurrentInsurer</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>License Plate Province</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>EngineNumber</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ChassisNumber</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>Added Accessories Or Modifications?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>Accessories or Modifications Cost</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Any Claims in the Last Year?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>CommencementDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>CTPL</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>CTPL Amount</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>Premium</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ApplicationDate</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            else if (Language == "TH")
            {
                _html += "<html><body><table width='60%' cellpadding='1' cellspacing='1' border='1'>";
                _html += "<tr><td align='left' colspan='2'><b>รายละเอียดผู้ทำประกัน</b></td></tr>";
                _html += "<tr><td width='300' align='left'><b>คำนำหน้า</b></td><td  align='left'>" + Title + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ชื่อผู้ทำประกัน</b></td><td  align='left'>" + Name + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เลขที่บัตรประชาชน</b></td><td style='mso-number-format:0' align='left'>" + IdentificationNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันเกิด</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + DOB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เพศ</b></td><td  align='left'>" + Gender + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>อาชีพ</b></td><td  align='left'>" + Occupation + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เบอร์ติดต่อ</b></td><td style='mso-number-format:\\@' align='left'>" + ContactNo + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ที่อยู่ปัจจุบัน</b></td><td  align='left'>" + PresentAddress + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แขวง/ตำบล</b></td><td  align='left'>" + SubDistrict + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>เขต/อำเภอ</b></td><td  align='left'>" + District + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัด</b></td><td  align='left'>" + Province + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รหัสไปรษณีย์</b></td><td  align='left'>" + PostalCode + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกัน</b></td><td  align='left'>โตเกียวมารีนศรีเมือง</td></tr>";
                _html += "<tr><td width='300' align='left'><b>แพกเก็จ</b></td><td  align='left'>" + CoverType + "</td></tr>";

                _html += "<tr><td width='300' align='left'><b>ระบุผู้ขับขี่</b></td><td  align='left'>" + AddDrivers + "</td></tr>";
                if (AddDrivers == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวนผู้ขับขี่</b></td><td  align='left'>" + NoOfDriver + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 0)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 1</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB1 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 1</b></td><td  align='left'>" + DriverLicenseNo1 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 1)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 2</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB2 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 2</b></td><td  align='left'>" + DriverLicenseNo2 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 2)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 3</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB3 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 3</b></td><td  align='left'>" + DriverLicenseNo3 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 3)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 4</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB4 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 4</b></td><td  align='left'>" + DriverLicenseNo4 + "</td></tr>";
                }
                if (Convert.ToInt16(NoOfDriver) > 4)
                {
                    _html += "<tr><td width='300' align='left'><b>วันเกิด ผู้ขับขี่คนที่ 5</b></td><td  style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + DriverDOB5 + "</td></tr>";
                    _html += "<tr><td width='300' align='left'><b>เลขที่ใบขับขี่คนที่ 5</b></td><td  align='left'>" + DriverLicenseNo5 + "</td></tr>";
                }

                _html += "<tr><td width='300' align='left'><b>ประเภทประกัน</b></td><td  align='left'>" + InsuranceType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทอู่</b></td><td  align='left'>" + GarageType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ปีของรถ</b></td><td  align='left'>" + CarModelYear + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>รุ่น</b></td><td  align='left'>" + CarMakeModel + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ขนาด (cc.)</b></td><td  align='left'>" + Displacement + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>น้ำหนักรถ (kgs)</b></td><td align='left'>" + VehicleWeight + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จำนวนที่นั่ง</b></td><td  align='left'>" + NumberofSeat + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ผู้รับผลประโยชน์</b></td><td  align='left'>" + Beneficiary + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ประเภทรถ</b></td><td  align='left'>" + VehicleType + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทุนประกัน</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + SumInsured + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ส่วนลด NCB</b></td><td  align='left'>" + NCB + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>บริษัทประกันปัจจุบัน</b></td><td  align='left'>" + CurrentInsurer + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>ทะเบียนรถ</b></td><td  align='left'>" + CarPlate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>จังหวัดที่จดทะเบียน</b></td><td  align='left'>" + ProvinceRegistration + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลขเครื่อง</b></td><td  align='left'>" + EngineNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>หมายเลข Chassis</b></td><td  align='left'>" + ChassisNumber + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>มีอุปกรณ์พิเศษ?</b></td><td  align='left'>" + Accessories + "</td></tr>";
                if (Accessories == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>ราคาของอุปกรณ์พิเศษ</b></td><td  align='left'>" + ModifyCost + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>มีการเคลมปีที่แล้วหรือไม่?</b></td><td>" + AnyClaims + "</td></tr>";
                _html += "<tr><td width='300'  align='left'><b>วันที่เริ่มทำประกัน</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy'  align='left'>" + CommencementDate + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>พ.ร.บ.</b></td><td  align='left'>" + CTPL + "</td></tr>";
                if (CTPL == "Yes")
                {
                    _html += "<tr><td width='300' align='left'><b>จำนวน (พ.ร.บ.)</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + CTPLAmount + "</td></tr>";
                }
                _html += "<tr><td width='300' align='left'><b>ราคารวม</b></td><td style='mso-number-format:\\#\\,\\#\\#0\\.00'  align='left'>" + TotalPremium + "</td></tr>";
                _html += "<tr><td width='300' align='left'><b>วันที่ทำรายการ</b></td><td style='mso-number-format:dd\\-mmm\\-yyyy\\ hh\\:mm\\ AM\\/PM'  align='left'>" + ApplicationDate + "</td></tr>";
                
                _html += "</table></body></html>";
            }
            #endregion
        }
        return _html;
    }

    public void ExportGridView(string fileName, Label lblContent)
    {
        string attachment = "attachment; filename=" + fileName + ".xls";
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/ms-excel";
        Response.Write(lblContent.Text);
        Response.End();
    }

    //Select Option
    protected void ddlOption_SelectedIndexChanged(object sender, EventArgs e)
    {
        Span1.InnerHtml = "";
        txtReceiptNo.Text = "";
        txtiPayReceiptNo.Text = "";
        txtRemark.Text = "";
        if (ddlOption.Text == "CONT")
        {
            //pnlUpload.Visible = false;
            pnlDetails.Visible = false;
            pnlContinue.Visible = true;
            pnlTryAgain.Visible = false;
            pnlChangePaymentType.Visible = false;
            pnliPay.Visible = false;
            pnlApplicationCancel.Visible = false;
            pnlApplicationRetrieve.Visible = false;
        }
        else if (ddlOption.Text == "TABP")
        {
            //pnlUpload.Visible = false;
            pnlDetails.Visible = false;
            pnlContinue.Visible = false;
            pnlTryAgain.Visible = true;
            pnlChangePaymentType.Visible = false;
            pnliPay.Visible = false;
            pnlApplicationCancel.Visible = false;
            pnlApplicationRetrieve.Visible = false;
        }
        else if (ddlOption.Text == "IPAY")
        {
            //pnlUpload.Visible = false;
            pnlDetails.Visible = false;
            pnlContinue.Visible = false;
            pnlTryAgain.Visible = false;
            pnlChangePaymentType.Visible = false;
            pnliPay.Visible = true;
            pnlApplicationCancel.Visible = false;
            pnlApplicationRetrieve.Visible = false;
        }
        else if (ddlOption.Text == "BTPT" || ddlOption.Text == "CCPT")
        {
            //pnlUpload.Visible = false;
            pnlDetails.Visible = false;
            pnlContinue.Visible = false;
            pnlTryAgain.Visible = false;
            pnlChangePaymentType.Visible = true;
            pnliPay.Visible = false;
            pnlApplicationCancel.Visible = false;
            pnlApplicationRetrieve.Visible = false;
            lblPayType.Text = "";
            if (ddlOption.Text == "BTPT")
            {
                lblPayType.Text = Resources.CarInsurance.BankInChangePaymentType;
            }
            else if (ddlOption.Text == "CCPT")
            {
                lblPayType.Text = Resources.CarInsurance.CreditCardChangePaymentType;
            }
        }
        else if (ddlOption.Text == "CRAP")
        {
            //pnlUpload.Visible = false;
            pnlDetails.Visible = false;
            pnlContinue.Visible = false;
            pnlTryAgain.Visible = false;
            pnlChangePaymentType.Visible = false;
            pnliPay.Visible = false;
            pnlApplicationCancel.Visible = true;
            pnlApplicationRetrieve.Visible = false;
        }
        else if (ddlOption.Text == "PROC")
        {
            ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
            pnlUpload.Visible = true;
            pnlDetails.Visible = false;
            pnlContinue.Visible = false;
            pnlTryAgain.Visible = false;
            pnlChangePaymentType.Visible = false;
            pnliPay.Visible = false;
            pnlApplicationCancel.Visible = false;
            pnlApplicationRetrieve.Visible = false;
        }
        else if (ddlOption.Text == "RTRV")
        {
            //pnlUpload.Visible = false;
            pnlDetails.Visible = false;
            pnlContinue.Visible = false;
            pnlTryAgain.Visible = false;
            pnlChangePaymentType.Visible = false;
            pnliPay.Visible = false;
            pnlApplicationCancel.Visible = false;
            pnlApplicationRetrieve.Visible = true;
        }
        else
        {
            //pnlUpload.Visible = false;
            pnlDetails.Visible = false;
            pnlContinue.Visible = false;
            pnlTryAgain.Visible = false;
            pnlChangePaymentType.Visible = false;
            pnliPay.Visible = false;
            pnlApplicationCancel.Visible = false;
            pnlApplicationRetrieve.Visible = false;
        }
    }

    protected void btnContinue_Click(object sender, EventArgs e)
    {
        txtLastQuoteRefNo.Text = lblUpRefNo.Text.Trim();
        Page.Validate();
        if (Page.IsValid)
        {
            Int64 _result = -1;
            Int32 WorkType = 0;
            Int32 SubmitType = 0;
            string OrderRefNo = txtOrderRefNo.Text.Trim();
            Int64 ProviderId = Convert.ToInt64(txtProviderId.Text.Trim());
            string ReceiptNo = Server.HtmlEncode(txtReceiptNo.Text.Trim());
            Int64 AgentId = Convert.ToInt64(Session[General.UserId].ToString());
            if (txtSubmitedType.Text != "")
            {
                SubmitType = Convert.ToInt32(txtSubmitedType.Text.Trim());
            }

            if (SubmitType == 0 && lblUpPaymentType.Text == "BT")
            {
                WorkType = 101;
            }
            else if (SubmitType == 0 && lblUpPaymentType.Text == "CC")
            {
                WorkType = 201;
            }
            else if (SubmitType > 0 && lblUpPaymentType.Text == "BT")
            {
                WorkType = 102;
            }
            else if (SubmitType > 0 && lblUpPaymentType.Text == "CC")
            {
                WorkType = 202;
            }
            ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
            if (lblUpPaymentType.Text == "BT")
            {
                _result = _proposalsummarydb.UpdateBankInPaymentStatus(OrderRefNo, ProviderId, ReceiptNo, AgentId, WorkType);
            }
            else if (lblUpPaymentType.Text == "CC")
            {
                _result = _proposalsummarydb.UpdateCreditCardPaymentStatus(OrderRefNo, ProviderId, ReceiptNo, AgentId, WorkType);
            }
            if (_result > 0)
            {
                
                pnlOptionMessage.Visible = true;
                lblOptionMessage.Text = Resources.CarInsurance.SuccessReceiptNoUpdate;
             
                LoadApplicationDetails();
                if (txtCarId.Text.Trim() != "")
                {
                    GetPaymentDetails();
                    GetCarMoreDetails();
                }
                if (txtCancelStatus.Text != "" && Convert.ToInt32(txtCancelStatus.Text.Trim()) > 0)
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Retrieve, "RTRV"));
                }
            }
        }
    }

    //Payment - Try Again
    protected void btnTryAgain_Click(object sender, EventArgs e)
    {
        txtLastQuoteRefNo.Text = lblUpRefNo.Text.Trim();
        if (txtOrderRefNo.Text != "")
        {
            MyDatabase _db = new MyDatabase();
            float _fAmount = 0.0f;
            string strSql = "SELECT CAST(AnnualPremium AS NUMERIC(10,2)) AS AnnualPremium FROM tblCarInsuranceSelectItemTH WHERE OrderRefNo  = '" + txtOrderRefNo.Text + "'";
            object _result = _db.ExecuteScalarSqlStatement(strSql);
            if (_result != null)
            {
                _fAmount = Convert.ToSingle(_result.ToString());
            }

            string _strAmount, eAmount, _strOrderRefNo, eOrderRefNo;
            _strAmount = ""; eAmount = ""; _strOrderRefNo = ""; eOrderRefNo = "";
            string key = "cxDAtravel";
            CXDecryption.Decryption cxd = new CXDecryption.Decryption();
            _strAmount = _fAmount.ToString();
            _strOrderRefNo = txtOrderRefNo.Text;
            if (_strAmount.ToString() != "" && _strAmount.ToString() != null)
            {
                byte[] Amount = cxd.Encrypt(_strAmount, key);
                eAmount = Convert.ToBase64String(Amount);
            }
            if (_strOrderRefNo.ToString() != "" && _strOrderRefNo.ToString() != null)
            {
                byte[] OrderRefNo = cxd.Encrypt(_strOrderRefNo, key);
                eOrderRefNo = Convert.ToBase64String(OrderRefNo);
            }
            string URL = ConfigurationManager.AppSettings["TH.BKKPaymentPage"].ToString();
            URL += "?pa=" + eAmount + "&orno=" + eOrderRefNo;
            //Response.Redirect(URL);

            StringBuilder sb = new StringBuilder();
            sb.Append("<script>");
            sb.Append("window.open('" + URL + "', '', '');");
            sb.Append("</scri");
            sb.Append("pt>");
            Page.RegisterStartupScript("test", sb.ToString());

        }
    }

    //Ipay
    protected void btnIpayProceed_Click(object sender, EventArgs e)
    {
        txtLastQuoteRefNo.Text = lblUpRefNo.Text.Trim();
        Page.Validate();
        if (Page.IsValid)
        {
            Int64 _result = -1;
            Int32 WorkType = 0;
            Int32 SubmitType = 0;
            string OrderRefNo = txtOrderRefNo.Text.Trim();
            Int64 ProviderId = Convert.ToInt64(txtProviderId.Text.Trim());
            string ReceiptNo = Server.HtmlEncode(txtiPayReceiptNo.Text.Trim());
            Int64 AgentId = Convert.ToInt64(Session[General.UserId].ToString());
            if (txtSubmitedType.Text != "")
            {
                SubmitType = Convert.ToInt32(txtSubmitedType.Text.Trim());
            }

            if (SubmitType == 0 && lblUpPaymentType.Text == "CC")
            {
                WorkType = 301;
            }
            else if (SubmitType > 0 && lblUpPaymentType.Text == "CC")
            {
                WorkType = 302;
            }
            ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
            _result = _proposalsummarydb.UpdateCreditCardPaymentStatus(OrderRefNo, ProviderId, ReceiptNo, AgentId, WorkType);
            if (_result > 0)
            {
                
                pnlOptionMessage.Visible = true;
                lblOptionMessage.Text = Resources.CarInsurance.SuccessIPay;
           
                LoadApplicationDetails();
                if (txtCarId.Text.Trim() != "")
                {
                    GetPaymentDetails();
                    GetCarMoreDetails();
                }
                if (txtCancelStatus.Text != "" && Convert.ToInt32(txtCancelStatus.Text.Trim()) > 0)
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Retrieve, "RTRV"));
                }
            }
        }
    }

    //Change Payment Type
    protected void btnChangePaymentType_Click(object sender, EventArgs e)
    {
        txtLastQuoteRefNo.Text = lblUpRefNo.Text.Trim();
        Int64 _result = -1;
        string OrderRefNo = txtOrderRefNo.Text.Trim();
        Int64 ProviderId = Convert.ToInt64(txtProviderId.Text.Trim());
        string PaymentType = "Bank In";
        Int64 AgentId = Convert.ToInt64(Session[General.UserId].ToString());
        if (lblUpPaymentType.Text == "BT")
        {
            PaymentType = "CreditCard";
        }
        else if (lblUpPaymentType.Text == "CC")
        {
            PaymentType = "Bank In";
        }
        ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
        _result = _proposalsummarydb.UpdatePaymentType(OrderRefNo, ProviderId, PaymentType, AgentId);
        if (_result > 0)
        {
            if (lblUpPaymentType.Text == "BT")
            {
               
                lblOptionMessage.Text = Resources.CarInsurance.SuccessChangeCC;
            }
            else if (lblUpPaymentType.Text == "CC")
            {
             
                lblOptionMessage.Text = Resources.CarInsurance.SuccessChangeBT;
            }
            pnlOptionMessage.Visible = true;
           
            LoadApplicationDetails();
            if (txtCarId.Text.Trim() != "")
            {
                GetPaymentDetails();
                GetCarMoreDetails();
            }
            if (txtCancelStatus.Text != "" && Convert.ToInt32(txtCancelStatus.Text.Trim()) > 0)
            {
                ddlOption.Items.Clear();
                ddlOption.Items.Add(new ListItem("Please Select", "0"));
                ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Retrieve, "RTRV"));
            }
        }
    }

    //Application Cancel
    protected void btnApplicationCancel_Click(object sender, EventArgs e)
    {
        txtLastQuoteRefNo.Text = lblUpRefNo.Text.Trim();
        Page.Validate();
        if (Page.IsValid)
        {
            Int64 _result = -1;
            Int16 Step = 1;
            string OrderRefNo = txtOrderRefNo.Text.Trim();
            Int64 ProviderId = Convert.ToInt64(txtProviderId.Text.Trim());
            string Remarks = Server.HtmlEncode(txtRemark.Text.Trim());
            Int64 AgentId = Convert.ToInt64(Session[General.UserId].ToString());

            ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
            _result = _proposalsummarydb.UpdateApplicationCancelStatus(OrderRefNo, ProviderId, AgentId, Step, Remarks);
            if (_result > 0)
            {
                
                lblOptionMessage.Text = Resources.CarInsurance.SuccessCancelApplication;
                pnlOptionMessage.Visible = true;
            
                LoadApplicationDetails();
                if (txtCarId.Text.Trim() != "")
                {
                    GetPaymentDetails();
                    GetCarMoreDetails();
                }
                if (txtCancelStatus.Text != "" && Convert.ToInt32(txtCancelStatus.Text.Trim()) > 0)
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Retrieve, "RTRV"));
                }
            }
        }
    }

    //Application Retrieve
    protected void btnApplicationRetrieve_Click(object sender, EventArgs e)
    {
        txtLastQuoteRefNo.Text = lblUpRefNo.Text.Trim();
        Page.Validate();
        if (Page.IsValid)
        {
            Int64 _result = -1;
            Int16 Step = 2;
            string OrderRefNo = txtOrderRefNo.Text.Trim();
            Int64 ProviderId = Convert.ToInt64(txtProviderId.Text.Trim());
            Int64 AgentId = Convert.ToInt64(Session[General.UserId].ToString());

            ProposalSummaryDB _proposalsummarydb = new ProposalSummaryDB();
            _result = _proposalsummarydb.UpdateApplicationRetrieveStatus(OrderRefNo, ProviderId, AgentId, Step);
            if (_result > 0)
            {
              
                lblOptionMessage.Text = Resources.CarInsurance.SuccessRetrieveApplication;
                pnlOptionMessage.Visible = true;
                
                LoadApplicationDetails();
                if (txtCarId.Text.Trim() != "")
                {
                    GetPaymentDetails();
                    GetCarMoreDetails();
                }
                if (txtCancelStatus.Text != "" && Convert.ToInt32(txtCancelStatus.Text.Trim()) > 0)
                {
                    ddlOption.Items.Clear();
                    ddlOption.Items.Add(new ListItem("Please Select", "0"));
                    ddlOption.Items.Add(new ListItem(Resources.CarInsurance.Retrieve, "RTRV"));
                }
            }
        }
    }

    protected void csvIsFile_ServerValidate(object source, ServerValidateEventArgs args)
    {
        txtIsFile.Text = "";
        txtIsFile.Text = "valid";
        HttpFileCollection uploads;
        uploads = HttpContext.Current.Request.Files;
        for (int a = 0; a < uploads.Count; a++)
        {
            if (uploads[a].ContentLength > 0)
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
                ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
            }
        }
        if (uploads.Count == 0)
        {
            args.IsValid = false;
            ScriptManager.RegisterStartupScript(ddlOption, ddlOption.GetType(), Guid.NewGuid().ToString(), "ShowHideDiv('divUpload',true);", true);
        }
        else
        {
            args.IsValid = true;
        }
    }

    

}
